package org.farng.mp3.id3;

import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectNumberHashMap;
import org.farng.mp3.object.ObjectStringHashMap;
import org.farng.mp3.object.ObjectStringSizeTerminated;

import java.io.IOException;


/**
 * Title: Description: Copyright:    Copyright (c) 2002 Company:
 *
 * @author Eric Farng
 * @version $Revision: 1.3 $
 */
public class FrameBodyUSER extends AbstractID3v2FrameBody {
    /**
     * Creates a new FrameBodyUSER object.
     */
    public FrameBodyUSER() {
        //        setObject("Text Encoding", new Byte((byte) 0));
        //        setObject("Language", "");
        //        setObject("Text", "");
    }

    public FrameBodyUSER(FrameBodyUSER body) {
        super(body);
    }

    /**
     * Creates a new FrameBodyUSER object.
     *
     * @param textEncoding DOCUMENT ME!
     * @param language DOCUMENT ME!
     * @param text DOCUMENT ME!
     */
    public FrameBodyUSER(byte textEncoding, String language, String text) {
        setObject("Text Encoding", new Byte(textEncoding));
        setObject("Language", language);
        setObject("Text", text);
    }

    /**
     * Creates a new FrameBodyUSER object.
     *
     * @param file DOCUMENT ME!
     *
     * @throws IOException DOCUMENT ME!
     * @throws InvalidTagException DOCUMENT ME!
     */
    public FrameBodyUSER(java.io.RandomAccessFile file)
                  throws IOException, InvalidTagException {
        this.read(file);
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getIdentifier() {
        return "USER" + ((char) 0) + getLanguage();
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getLanguage() {
        return (String) getObject(ObjectStringHashMap.LANGUAGE);
    }

    /**
     * DOCUMENT ME!
     *
     * @param language DOCUMENT ME!
     */
    public void setOwner(String language) {
        setObject(ObjectStringHashMap.LANGUAGE, language);
    }

    /**
     * DOCUMENT ME!
     */
    protected void setupObjectList() {
        objectList.add(new ObjectNumberHashMap(ObjectNumberHashMap.TEXT_ENCODING, 1));
        objectList.add(new ObjectStringHashMap(ObjectStringHashMap.LANGUAGE, 3));
        objectList.add(new ObjectStringSizeTerminated("Text"));
    }
}